package com.lx.spring.config.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;


//

/**
 * BeanPostProcessor 为各种 bean初始化执行器的父接口,其子类的在spring框架中的各种作用可以了解下
 * 其实现包含有 :
 * ApplicationContextAwareProcessor 可以获取到当前 ApplicationContext
 *      通过执行 ApplicationContextAware 实现类的 setApplicationContext() 方法
 *
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("MyBeanPostProcessor Before " +beanName);
        return bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("MyBeanPostProcessor After "+beanName);
        return bean;
    }
}
